package br.com.duosoftware.orcamento.managedbeans;

import br.com.duosoftware.orcamento.enums.Relatorio;
import br.com.duosoftware.orcamento.services.RelatorioService;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author daniel
 *
 */
@ManagedBean
@ViewScoped
public class RelatorioBean implements Serializable {
    
    private Relatorio relatorio;
    
    private RelatorioService relatorioService;

    public RelatorioBean() {

        relatorioService = new RelatorioService();

    }

    public Relatorio getRelatorio() {
        return relatorio;
    }

    public void setRelatorio(Relatorio relatorio) {
        this.relatorio = relatorio;
    }
    
    public Relatorio[] getRelatorios() {
        return Relatorio.values();
    }
    
    public void imprimirRelatorio(){
    
        try {
            
            relatorioService.imprimirRelatorio(relatorio.getDiretorio(), relatorio.getNome());
            
        } catch (Exception e) {
            
            Logger.getLogger(RelatorioBean.class.getName()).log(Level.SEVERE, null, e);
            
        }
        
    }
    
}
